//
//  ArrearagesVC.m
//  XinTaiPub
//
//  Created by rzhyios on 2018/6/1.
//  Copyright © 2018年 rzhy. All rights reserved.
//

#import "ArrearagesVC.h"
#import "Config.h"
#import <UIScrollView+EmptyDataSet.h>
#import "Patient.h"
#import "ArrearagesCell.h"

@interface ArrearagesVC ()<UITableViewDelegate, UITableViewDataSource>
{
    Patient *_patient;
    NSArray *_dataArray;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation ArrearagesVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"缴款信息";
    _patient = [Patient sharedPatient];
    // self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.tableView registerNib:[UINib nibWithNibName:@"ArrearagesCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"ArrearagesCell"];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self getZyjkjl];
}

#pragma mark - 缴款信息
- (void)getZyjkjl {
    NSDictionary *cookie = @{CookieVaule : [UserDefaultsTool stringForKey:XHToken]};
    NSDictionary *param = @{@"id" : @(_patient.id)};
    [HTTPSTool POSTRequestWithPath:XHUserZyckjl cookie:cookie params:param success:^(NSDictionary * _Nonnull JSON) {
        XHLog(@"缴款信息 -> JSON: %@", JSON);
        _dataArray = JSON[@"data"][@"list"];
        [self.tableView reloadData];
    }];
}

#pragma mark - tableView delegate/dataSource Method
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _dataArray.count;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     ArrearagesCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ArrearagesCell"];
        NSDictionary *dict = _dataArray[indexPath.row];
    if (indexPath.section == 0) {
        cell.dateLabel.textColor = [UIColor redColor];
        cell.numberLabel.textColor = [UIColor redColor];
        cell.priceLabel.textColor = [UIColor redColor];
    }else{
        cell.dateLabel.text = dict[@"ckrq"];
        cell.numberLabel.text = dict[@"zyhm"];
        cell.priceLabel.text = dict[@"ckje"];
    }
    return cell;
}



@end
